package android.slc.appbase.ui.vd;

import android.os.Bundle;

import androidx.activity.result.ActivityResultLauncher;

import java.io.Serializable;

/**
 * 基础的详细盒子vm
 *
 * @author slc
 * @date 2020-08-25 16:13
 */
public class BaseCommonDetailsShelfVd<T extends Serializable, VB extends BaseCommonDetailsShelfVmBox<T>> extends BaseDataChangeVd<VB> {

    protected ActivityResultLauncher<Bundle> editActivityResultLauncher;

    @Override
    protected void initView() {
        super.initView();
        if (this.vmBox.editRegisterActivityFunc != null) {
            editActivityResultLauncher = this.activityResultCaller.registerForActivityResult(
                    this.vmBox.editRegisterActivityFunc.getTargetActivityResultContract(),
                    this.vmBox.editRegisterActivityFunc.getOnTargetActivityResultCallback()
            );
        }

    }

    @Override
    protected void initMustCondition() {
        super.initMustCondition();
        this.vmBox.showEditUiOf.observe(lifecycleOwner, bundle ->
                editActivityResultLauncher.launch(bundle)
        );
    }
}
